package code07_面向对象;

/*
 * 汽车管理系统
 */
public class Test01_产生 {
	public static void main(String[] args) {
		/*
		 * 使用基本数据类型，存储一辆车的信息
		 * 缺点：变量太多
		 */
		String name = "宝马";
		String color = "黑色";
		int speed = 60;
		double price = 35.4;
		String direction = "东";

		/*
		 * 使用数组，存储多辆车的信息
		 * 缺点：信息太分散
		 */
		String[] names = new String[5];
		String[] colors = new String[5];
		int[] speeds = new int[5];
		double[] prices = new double[5];
		String[] directions = new String[5];
		names[0] = "奥迪";
		colors[0] = "红色";
		speeds[0] = 60;
		prices[0] = 34.7;
		directions[0] = "西";

		/*
		 * 使用面向对象，存储车辆的信息
		 */
		// 1.创建类的对象，语法：类名 对象名 ＝ new 类名()
		Car car1 = new Car();
		// 2.为属性赋值，语法：对象名.属性名
		car1.name = "奔驰";
		car1.color = "白色";
		car1.price = 12.5;
		car1.speed = 34;
		car1.direction = "南";
		// 3.获取属性
		System.out.println("品牌：" + car1.name);
		System.out.println("颜色：" + car1.color);
		System.out.println("速度：" + car1.speed);
		System.out.println("价格：" + car1.price);
		System.out.println("方向：" + car1.direction);
		// 4.调用方法，语法：对象名.方法名()
		car1.run();

		// 定义(声明)一个汽车类型的变量
		Car car2;
		car2 = new Car();

		// int a = 5;
		int a;
		a = 5;

	}
}
